<?php

//PLUGIN type=action
//PLUGIN name=module.add
//PLUGIN desc=Enables you to add modules to your pages
//PLUGIN group=native


    $new_mod = $c_xml->content->addChild('module');
    $new_mod->addChild('id', (string) time() . "_" . (string) rand(100, 999));
    $new_mod->addChild('folder', $_POST['module']);
    $new_mod->addChild('data', 'data');
    $new_mod->addChild('panel', $_POST['panel']);
    if (!file_exists($p = $c_path . "!content/" . (string) $new_mod->id))
    {
        mkdir($p);
    }
    if (!file_exists($f = $p . "/" . $new_mod->data))
    {
        file_put_contents($f, "");
    }
    file_put_contents($c_xml_file, $c_xml->asXML());
    header("Location:.?q=command:cms;view:cms.editor;page:" . $c_site['meta']['page']);
?>